package com.iqiyi.pps.epg.core.dao.statistic;

import com.iqiyi.pps.epg.api.model.web.statistic.TStatisticAutoNewData;
import com.iqiyi.pps.epg.core.dao.base.BaseDao;
import com.iqiyi.pps.epg.core.model.statistic.StatisticAutoNewData;
import com.iqiyi.pps.epg.core.utils.DateTimeUtil;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/1/25.
 */
@Component
public class StatisticAutoNewDataDao extends BaseDao<StatisticAutoNewData> {
    public List<TStatisticAutoNewData> transToThriftList(List<StatisticAutoNewData> dataList) {
        List<TStatisticAutoNewData> resultList = new ArrayList<>();
        TStatisticAutoNewData tChannelLog = null;
        for (StatisticAutoNewData tempData : dataList) {
            tChannelLog = transToThrift(tempData);
            resultList.add(tChannelLog);
        }
        return resultList;
    }

    public TStatisticAutoNewData transToThrift(StatisticAutoNewData tempData) {
        TStatisticAutoNewData thriftData = new TStatisticAutoNewData();
        thriftData.setId(tempData.getId());
        thriftData.setUser(tempData.getUser());
        thriftData.setAddTime(DateTimeUtil.transLongFormat(tempData.getAddTime().getTime()));
        thriftData.setAutoTitle(tempData.getAutoTitle());
        thriftData.setUserTitle(tempData.getUserTitle());
        thriftData.setAutoFlag(tempData.getAutoFlag());
        thriftData.setAutoTitleCharLen(tempData.getAutoTitleCharLen());
        thriftData.setUserTitleCharLen(tempData.getUsrTitleCharLen());
        thriftData.setLiveBeginTime(DateTimeUtil.transLongFormat(tempData.getLiveBeginTime().getTime()));
        thriftData.setLiveEndTime(DateTimeUtil.transLongFormat(tempData.getLiveEndTime().getTime()));
        thriftData.setPercent(tempData.getPercent());
        thriftData.setChannelName(tempData.getChannelName());
        thriftData.setTitleError(tempData.getTitleError() );
        thriftData.setLegoProgramId(tempData.getLegoProgramId());
        thriftData.setAutoTitleStart(tempData.getAutoTitleStart());
        thriftData.setAutoTitleEnd(tempData.getAutoTitleEnd());
        thriftData.setUserTitleSelect(tempData.getUserTitleSelect());
        return thriftData;
    }
}
